
'''
    for循环实现乘法表
'''

print('='*30,'for1','='*30)
for row in range(1,10):
    for col in range(1,row+1):
        print('{}*{}={:<4}'.format(col,row,row*col),end='')
    print('')

print('='*30,'for2','='*30)

for row in range(9,0,-1):
    for col in range(1,row+1):
        print('{}*{}={:<4}'.format(col,row,row*col),end='')
    print('')


print('='*30,'for3','='*30)
for row in range(1,10):
    line = ''
    for col in range(1,row+1):
        line = '{}*{}={:<4}'.format(col,row,row*col)+line;
    print('{:>72}'.format(line))
print('='*70)

for row in range(9,0,-1):
    line = ''
    for col in range(1,row+1):
        line = '{}*{}={:<4}'.format(col,row,row*col)+line;
    print('{:>72}'.format(line))

'''
    while循环实现
'''

print('='*30,'while1','='*30)
row = 1
col = 1
while row < 10:
    while col < row+1:
        print('{}*{}={:<4}'.format(col, row, row * col), end='')
        col += 1
    print('')
    col = 1;
    row +=1


print('='*30,'while2','='*30)
row = 9
col = 1
while row >0:
    while col < row+1:
        print('{}*{}={:<4}'.format(col, row, row * col), end='')
        col += 1
    print('')
    col = 1;
    row -=1


print('='*30,'while3','='*30)
row = 1
col = 1
while row < 10:
    line = ''
    while col < row+1:
        line = '{}*{}={:<4}'.format(col, row, row * col)+line
        col  += 1
    print('{:>72}'.format(line))
    col = 1
    row +=1

print('='*30,'while4','='*30)
row = 9
col = row
while row > 0:
    line = ''
    while col >0:
        line += '{}*{}={:<4}'.format(col, row, row * col)
        col  -= 1
    print('{:>72}'.format(line))
    row -=1
    col = row